
package com.wyzz.hr.action;

import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

import com.wyzz.hr.base.BaseAction;
import com.wyzz.hr.base.Constants;
import com.wyzz.hr.bo.IEmployeeBo;
import com.wyzz.hr.pojo.Employee;
import com.wyzz.hr.util.DatabaseSysConfigManager;
import com.wyzz.hr.util.SysConfigManager;

public class MyBasicInfo extends BaseAction implements Constants {

	public MyBasicInfo() {
		dbConfigManager = DatabaseSysConfigManager.getInstance();
	}

	public String execute() throws Exception {
		if (StringUtils.isEmpty(empName))
			empName = (String) (String) getSession().getAttribute("empName");
		exShiftEnable = dbConfigManager.getProperty("sys.examin.shift.enable")
				.trim();
		IEmployeeBo empBo = (IEmployeeBo) getBean("empBo");
		if (empNo != null && empNo.length() > 0) {
			Employee emp = empBo.loadEmp(empNo, null);
			if (emp == null)
				return "noemp";
			if ("OWN".equals(super.authorityCondition)
					&& !empNo.equals(getCurrentEmpNo()))
				return "noauth";
			if ("SUB".equals(super.authorityCondition)
					&& !empBo.checkEmpInCharge(getCurrentEmp(), emp))
				return "noauth";
		} else {
			empNo = getCurrentEmpNo();
		}
		logger.info((new StringBuilder()).append("empNo:").append(empNo)
				.toString());
		logger.info((new StringBuilder()).append("empName : ").append(empName)
				.toString());
		return "success";
	}

	public String getEmpNo() {
		return empNo;
	}

	public void setEmpNo(String empNo) {
		this.empNo = empNo;
	}

	public String getEmpName() {
		return empName;
	}

	public void setEmpName(String empName) {
		this.empName = empName;
	}

	public String getCreateFlag() {
		return createFlag;
	}

	public void setCreateFlag(String createFlag) {
		this.createFlag = createFlag;
	}

	private static final long serialVersionUID = 0xc53a77b0ae03eebfL;
	SysConfigManager dbConfigManager;
	String exShiftEnable;
	private static final Logger logger = Logger
			.getLogger(com.wyzz.hr.action.MyBasicInfo.class);
	private String empNo;
	private String empName;
	private String createFlag;

}
